#include <iostream>
using namespace std;
const int mo = 1000000007;
int n;
string s;
int cnt = 0;
int len = -1;
int ans = 0;
int main() {
    cin >> n >> s;
    for (int i = 0; i < n; i++) {
        if (s[i] == '0') {
            len = max(len, cnt);
            cnt = 0;
        } else
            cnt++;
    }

    int l = 0, r = 0, nowCount = 0;
    while (l < n && r < n) {
        while (r < n && nowCount < len) {
            if (s[r] == '0') {
                r++, nowCount = 0;
            } else {
                r++, nowCount++;
            }
        }
        
        for (int i = 0; i < r - len - l; i++) { ans = (ans + (n - r) % mo + 1) % mo; }
        l = r - len;
        nowCount = 0;
    }
    ans = (ans + (n - l - len + 1) % mo) % mo;
    cout << ans << endl;
    return 0;
}